<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class Userss extends Model
{
    //与模型关联的数据表 
    protected $table = 'Userss';

    //主键
    protected $primaryKey = 'id';

    // 该模型是否被自动维护时间戳 flase 不开启
    public $timestamps = true;

   //可以被批量赋值的属性
   protected $fillable = ['username','password','email','status','token','phone'];

   // 修改器
   public function getStatusAttribute($value)
   {
   		$status = [
   			1 => '激活',
   			0 => '禁用'
   		];

   		return $status[$value];
   }

   //关联方法 关联Userss和Userssinfo
   //一对一 hasOne ('要关联的模型类，关联字段')
   public function info() {
    return  $this->hasOne('App\Model\Userssinfo','userss_id');
   }

   //关联方法 关联Userss和adderss
   //一对多 hasMany('要关联的模型类，关联字段')
  public function address() {
    return $this->hasMany('App\Model\Userssaddress','user_id');
  }
}
